package top.gytf.unifiedcall.support.springcloud.producer;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.gytf.unifiedcall.common.detial.UnifiedCallPackageManager;
import top.gytf.unifiedcall.support.producer.UnifiedCallProducerProperties;

/**
 * SpringBoot的服务注册支持自动配置
 */
@Slf4j
@RequiredArgsConstructor
@Configuration(proxyBeanMethods = false)
public class SpringCloudServiceRegistrationSupportAutoConfiguration {
    private final UnifiedCallProducerProperties properties;

    @Bean
    public ServiceInstanceMetadataHandler serviceInstanceMetadataHandler(UnifiedCallPackageManager packageManager) {
        log.debug("注入 ServiceInstanceMetadataHandler, active-packages = {}", properties.getActivePackage());
        return new ServiceInstanceMetadataHandler(properties.getActivePackage(), packageManager);
    }
}
